class Entries < ActiveRecord::Migration
  def self.up
    rename_table :organizations, :groups
    
    drop_table :notes
    
    remove_column :action_items, :due
    remove_column :action_items, :name
    remove_column :action_items, :status
    remove_column :action_items, :blurb
    remove_column :action_items, :user_id
    
    remove_column :projects, :name
    remove_column :projects, :parent_id
    
    create_table "action_item_entries", :force => true do |t|
      t.column "name", :string
      t.column "note", :string
      t.column "status", :string, :default => "Closed"
      t.column "action_item_id", :integer, :null => false
      t.column "assigned_to", :integer
      t.column "created_by", :integer
      t.column "created_at", :datetime
      t.column "due", :datetime
    end
    
    create_table "project_entries", :force => true do |t|
      t.column "name", :string
      t.column "note", :string
      t.column "status", :string, :default => "Closed"
      t.column "project_id", :integer, :null => false
      t.column "created_by", :integer
      t.column "created_at", :datetime
      t.column "due", :datetime
      t.column "rank", :integer
    end
  end

  def self.down
    rename_table :groups, :organizations
    
    create_table :notes do |t|
      t.column "action_item_id", :integer, :null => false
      t.column "user_id", :integer, :null => false
      t.column "created_at", :datetime
      t.column "header", :string
      t.column "text", :text
    end
    
    add_column :action_items, :due, :datetime
    add_column :action_items, :name, :string
    add_column :action_items, :status, :string
    add_column :action_items, :blurb, :string
    add_column :action_items, :user_id, :integer
    
    add_column :projects, :name, :string
    add_column :projects, :parent_id, :integer
  end
end
